package com.zrc.japktool.apk.lib2cppTools.tools;

import java.io.File;
import java.io.IOException;

public class DumperHelper {
    String scriptFile;
    String il2cppHFile;
    private static volatile DumperHelper instance = null;

    private DumperHelper() {
        String path = SettingHelper.getInstance().getProjectPath();
        String OutPath = path + File.separator + "dump";

        try {
            FileHelper.mkdirs(OutPath);
        } catch (IOException var6) {
            throw new RuntimeException(var6);
        }

        String SoFile = path + File.separator + "app" + File.separator + "src" + File.separator + "main" + File.separator + "jniLibs" + File.separator + "arm64-v8a" + File.separator + "libil2cpp.so";
        String MetaDataFile = path + File.separator + "app" + File.separator + "src" + File.separator + "main" + File.separator + "static" + File.separator + "bin" + File.separator + "Data" + File.separator + "Managed" + File.separator + "Metadata" + File.separator + "global-metadata.dat";
        if (OSDetector.getOS() == OSDetector.win) {
            String objdumpCmd = "." + File.separator + "bin" + File.separator + "dump_net6.0" + File.separator + "Il2CppDumper.exe " + SoFile + " " + MetaDataFile + " " + OutPath;
            Cmd.run(objdumpCmd);
        } else if (OSDetector.getOS() == OSDetector.linux) {
            String[] objdumpCmd = new String[]{"." + File.separator + "bin" + File.separator + "dump_linux" + File.separator + "Il2CppDumper", SoFile, MetaDataFile, OutPath};
            Cmd.run(objdumpCmd, (String)null);
        }

        this.scriptFile = OutPath + File.separator + "script.json";
        this.il2cppHFile = OutPath + File.separator + "il2cpp.h";
    }

    public static DumperHelper getInstance() {
        if (instance == null) {
            synchronized(DumperHelper.class) {
                if (instance == null) {
                    instance = new DumperHelper();
                }
            }
        }

        return instance;
    }

    public String getScriptFile() {
        return this.scriptFile;
    }

    public String getil2cppHFile() {
        return this.il2cppHFile;
    }
}
